# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgname=spytrap-adb
pkgver=0.3.0
pkgrel=1
pkgdesc="Test a phone for stalkerware using adb and usb debugging to scan for suspicious apps and configuration"
url='https://github.com/spytrap-org/spytrap-adb'
arch=('loong64' 'x86_64')
license=('GPL-3.0-or-later')
depends=('android-tools')
makedepends=('cargo')
options=(!lto)
source=(https://github.com/spytrap-org/${pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('7592676c3bf289ada48c604caa112f0a2ad1dc0f8b53453b569d3849407b4031')
b2sums=('05f70e429530864b7f25e2e4443d70da2d2bd3b435d1c5c95ce2ae82d8d3a665d66f572528ce3f198ac8beb319e8d28fa7bdbcc70c188b9ea88a39c8d2f94644')

prepare() {
  cd "${pkgname}-${pkgver}"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd ${pkgname}-${pkgver}
  cargo build --frozen --release
}

check() {
  cd ${pkgname}-${pkgver}
  cargo test --frozen
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 -t "${pkgdir}/usr/bin" \
    target/release/spytrap-adb

  # install completions
  install -d "${pkgdir}/usr/share/bash-completion/completions" \
             "${pkgdir}/usr/share/zsh/site-functions" \
             "${pkgdir}/usr/share/fish/vendor_completions.d"
  "${pkgdir}/usr/bin/${pkgname}" completions bash > "${pkgdir}/usr/share/bash-completion/completions/${pkgname}"
  "${pkgdir}/usr/bin/${pkgname}" completions zsh > "${pkgdir}/usr/share/zsh/site-functions/_${pkgname}"
  "${pkgdir}/usr/bin/${pkgname}" completions fish > "${pkgdir}/usr/share/fish/vendor_completions.d/${pkgname}.fish"
}

# vim: ts=2 sw=2 et:
